var tokenStr = "",_PICNAME = "",_IMGPATH = "";
var isShowLocalData = false;//是否显示本地保存的数据
var _SERVER_DATA = "";//服务器返回的样方数据
var _DELETEWZ = [];//被删除的物种数据
var Eg_url = sysConfig.urlConfig.eg_url;
var Wz_url = sysConfig.urlConfig.wz_url;

$(function(){
    if (window.android != null && typeof (window.android) != "undefined") {
        tokenStr = window.android.callAndroidCurtUserToken();//获取当前token值
    }
	wzHtmlTabInit();//初始化物种信息表
	initAddBtn_Event();
	$('.imgs').click(function () {
        if($('.JG > div').children().length == 0){
                alert("没有图片可查看");
                return;
        }
        $('divdatapic').toggle();
    });

});
// 物种输入查询 --- 模糊查询
function	ZWdataYFone(i) {
    baidusearchinput["control_init"]($("input#text" + i + ""), $("input#hiddentext" + i + ""));
    baidusearchinput["control_init"]($("input#CBWZMC" + i + ""), $("input#CBWZDM" + i + ""));
}
// 草本的循环添加表单 CBloopTableshow
function wzHtmlTabInit(){
    let CByfID = $('input[name=CBtable]').val();
    let html = "";
    for(var i=1; i<= CByfID; i++){
        var CBtrtd = '<td>'
            + '<span><input class="CBzw q ZGDONE td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            + '<span><input class="CBzw q ZGDTWO td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            + '<span><input class="CBzw q ZGDTHREE td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            + '<span><input class="CBzw q ZGDFOUR td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            + '<span><input class="CBzw q ZGDFIVE td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            + '<span><input class="CBzw q ZGDAVE td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            + '</td>'
            + '<td><input class="CBzw ZCS td_input" type="text" oninput="clearNoNum(this)" value="0"></input></td>'
            + '<td>'
            + '<span><input class="CBzw SWLXZ td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            + '<span><input class="CBzw SWLGZ td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            + '</td>'
            + '<td class="djbz">备注'
            + '<div class="textarea">'
            + '<span class="CBzw BZ" contentEditable="true"></span>'
            + '<span class="button">确定</span>'
            + '</div>'
            + '</td>'
            + '<td class="YSZPIC"><divi onclick="YSZPIC(' + i + ')" style="display:block;text-align:center;">查看</divi><div class="YSZ' + i + '"><input type="hidden" /><div style="overflow:hidden;"><spans style="float:right;margin-right:8px;" onclick="YSZhide('+i+')">关闭</spans></div><hr><div class="YSZimg"></div></div></td>'
            + '<td onclick="WZdelete('+i+')">删除</td>';
        html += '<tr id="CBtr' + i + '"><td class="CBzw WZMC" style="position: relative;"><i class="fa fa-times" aria-hidden="true"><input name="SHBZVAL" class="SHBZVAL-YFMJ SHBZ-CB-WZ SHBZ-CB-WZ-'+(i-1)+'" type="hidden" value="0"/></i><input id="CBWZMC'+i+'" class="CBWZMC" type="text" name="wzmc" value="" onkeydown="ZWdataYFone(\''+i+'\')" placeholder="输入植物名称" style="width: 89%; outline: none; background: #6CBCFE; border: 0" /><input type="hidden" id="CBWZDM'+i+'" name="wzdm"/><input type="hidden" id="CBWZID'+i+'" name="CBwzid" value="0" /><input id="DBMARK'+i+'" type="hidden" value="0"/></td>' + CBtrtd  +'</tr>';
    }
    $("#form_CBidone .table_border tbody").html(html);
    $("#form_CBidone .table_border tbody tr td span input.ZGDAVE").on("click",function(){
        let sum1 = 0;
        let count = 0;
        $(this).parent().siblings().children().each(function(){
            if($(this).val() != null && $(this).val() != "" && $(this).val() != 0){
                sum1 += eval($(this).val());
                count ++;
            }
        });
        if(count == 0){
            $(this).val("");
        }else{
            $(this).val((sum1/count).toFixed(2));
        }
    });

}
//定义add_button的点击事件
function initAddBtn_Event(){
     // 点击增加草本样方表单 CBaddQuadratI
        $(".body .diplay4 .table .table_Herbaceous .table_border .add_button").hover(function(){
            $(this).css("background","#0271BC");
            $(this).css("cursor","pointer");
        },function(){
            $(this).css("background","");
            $(this).css("cursor","");
        });
        $("#form_CBidone .table_border tbody tr td.djbz").on("click",function(){
            $(this).children().show();
        });
        $("#form_CBidone .table_border tbody tr td .textarea .button").on("click",function(){
            $(this).parent().hide();
            return false;
        });
        $(".body .diplay4 .table .table_Herbaceous .table_border .add_button").on("click",function(){
            let number = parseInt($('input[name=CBtable]').val()) + 1;
            let CBtrtd = '<td>'
            +'<span><input class="CBzw q ZGDONE td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            +'<span><input class="CBzw q ZGDTWO td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            +'<span><input class="CBzw q ZGDTHREE td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            +'<span><input class="CBzw q ZGDFOUR td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            +'<span><input class="CBzw q ZGDFIVE td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            +'<span><input class="CBzw ZGDAVE td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            +'</td>'
            +'<td><input class="CBzw ZCS td_input" type="text" oninput="clearNoNum(this)" value="0"></input></td>'
            +'<td>'
            +'<span><input class="CBzw SWLXZ td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            +'<span><input class="CBzw SWLGZ td_input" type="text" oninput="clearNoNum(this)" value="0"></input></span>'
            +'</td>'
            +'<td class="djbz">备注'
            +'<div class="textarea">'
            +'<span class="CBzw BZ" contentEditable="true"></span>'
            +'<span class="button">确定</span>'
            +'</div>'
            +'</td>'
            + '<td class="YSZPIC"><divi onclick="YSZPIC(' + number + ')" style="display:block;text-align:center;">查看</divi><div class="YSZ' + number + '"><div style="overflow:hidden;"><spans style="float:right;margin-right:8px;" onclick="YSZhide('+number+')">关闭</spans></div><hr><div class="YSZimg"></div></div></td>'
            + '<td onclick="WZdelete(' + number +')">删除</td>';
            // var number = CByfID + 1;
            // var CByfID = $(".body .diplay4 .table .table_Herbaceous .table_border tr").length - 1

            $('input[name=CBtable]').val(number);
            let html = "";
            html += '<tr id="CBtr' + number + '"><td class="CBzw WZMC" style="position: relative;"><i class="fa fa-times" aria-hidden="true"><input name="SHBZVAL" class="SHBZVAL-YFMJ SHBZ-CB-WZ SHBZ-CB-WZ-'+number+'" type="hidden" value="0"/></i><input id="CBWZMC'+number+'" class="CBWZMC" type="text" name="wzmc" value="" onkeydown="ZWdataYFone(\''+number+'\')" placeholder="输入植物名称" style="width: 89%; outline: none; background: #6CBCFE; border: 0" /><input type="hidden" id="CBWZDM'+number+'" name="wzdm"/><input type="hidden" id="CBWZID'+number+'" name="CBwzid" value="0" /><input id="CBYFid'+number+'" type="hidden" name="CBYFid" value="CBYFid"/><input id="DBMARK'+number+'" type="hidden" value="1"/></td>' + CBtrtd  +'</tr>';
            $(".body .diplay4 .table .table_Herbaceous .table_border tbody").append(html);

            // 备注
            // 多行文本域
            $("#form_CBidone .table_border tbody tr td.djbz").on("click",function(){
                $(this).children().show();
            });
            $("#form_CBidone .table_border tbody tr td .textarea .button").on("click",function(){
                $(this).parent().hide();
                return false;
            });
            $("#form_CBidone .table_border tbody tr td .textarea .button").on("mouseover mouseout",function(event){
                if(event.type == "mouseover"){
                    $(this).css("background","#1978EE");
                    $(this).css("color","#fff");
                    $(this).css("cursor","pointer");
                }else if(event.type == "mouseout"){
                    $(this).css("background","");
                    $(this).css("color","");
                    $(this).css("cursor","");
                }
            });
            $("#form_CBidone .table_border tbody tr td span input.ZGDAVE").on("click",function(){
                let sum1 = 0;
                let count = 0;
                $(this).parent().siblings().children().each(function(){
                    if($(this).val() != null && $(this).val() != "" && $(this).val() != 0){
                        sum1 += eval($(this).val());
                        count ++;
                    }
                });
                if(count == 0){
                    $(this).val("");
                }else{
                  $(this).val((sum1/count).toFixed(2));
                }

            });
        });
}
//只能输入数字和小数点
function clearNoNum(obj){
 //先把非数字的都替换掉，除了数字和.
 obj.value = obj.value.replace(/[^\d.]/g,"");
 //必须保证第一个为数字而不是.
 obj.value = obj.value.replace(/^\./g,"");
 //保证只有出现一个.而没有多个.
 obj.value = obj.value.replace(/\.{2,}/g,".");
 //保证.只出现一次，而不能出现两次以上
 obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
}

//删除物种
function WZdelete(id) {
    $("#form_CBidone .table_border tbody #CBtr" + id + " td #DBMARK" + id + "").val(3);
    let str = JSON.stringify({
        WZDM: $("#form_CBidone .table_border tbody #CBtr" + id + " td #CBWZDM" + id + "").val(),
        WZMC: $("#form_CBidone .table_border tbody #CBtr" + id + " td #CBWZMC" + id + "").val(),
        ZGDONE: $("#form_CBidone .table_border tbody #CBtr" + id + ">td>span>input.ZGDONE").text(),
        ZGDTWO: $("#form_CBidone .table_border tbody #CBtr" + id + ">td>span>input.ZGDTWO").text(),
        ZGDTHREE: $("#form_CBidone .table_border tbody #CBtr" + id + ">td>span>input.ZGDTHREE").text(),
        ZGDFOUR: $("#form_CBidone .table_border tbody #CBtr" + id + ">td>span>input.ZGDFOUR").text(),
        ZGDFIVE: $("#form_CBidone .table_border tbody #CBtr" + id + ">td>span>input.ZGDFIVE").text(),
        ZGDAVG: $("#form_CBidone .table_border tbody #CBtr" + id + ">td>span>input.ZGDAVE").text(),
        CFLENGTH: "0",//丛幅长
        CFWIDTH: "0",//丛幅宽
        ZCS: $("#form_CBidone .table_border tbody #CBtr" + id + ">td>input.ZCS").text(),
        SWLXZ: $("#form_CBidone .table_border tbody #CBtr" + id + ">td>span>input.SWLXZ").text(),
        SWLGZ: $("#form_CBidone .table_border tbody #CBtr" + id + ">td>span>input.SWLGZ").text(),
        BZ: $("#form_CBidone .table_border tbody #CBtr" + id + ">td>div>span.BZ").text(),
        DBMARK:$("#form_CBidone .table_border tbody #CBtr" + id + " td #DBMARK" + id + "").val()
    });
    if($('#CBWZMC'+id).val() != ''){
        if (window.android != null && typeof (window.android) != "undefined") {
            window.android.callAndroidRemoveShowDialog(str,id);
        } else {
            alert(typeof (window.android));
        }
    }
}
//
function callJsRemoveWzInfo(deleteData,id) {
    _DELETEWZ.push(deleteData);//保存删除的数据
    $('#CBtr' + id).remove('tr');
    //alert('删除成功');
}
function callJsInitCbYfInfo(data){
    let yfCode = data.yfCode;
    $('.JG > div').empty();
    //window.android.callAndroidShowLog(JSON.stringify(data));
    //window.android.callAndroidShowLog(yfCode.split("-").length);
    if(yfCode.split("-").length == 1){
        $("#CBoneNameC").html(data.ydName);//样地名称
        $("#CBoneDm").val(data.ydCode);//样地代码
        $('#CBoneYFBHC').html(data.yfName.substring(data.yfName.lastIndexOf("方")+1));//样方编号
        $("#CBoneYFMJC").val("");//样方面积
        $("#CBoneZFGLC").val("");//总覆盖率
        $("#CBonePJGDC").val("");//平均高度
        wzHtmlTabInit();
    }else{
        cbYfQuery(yfCode);
    }

}
//执行页面初始化加载数据
function callJsWebViewInitComplete(){
     if (window.android != null && typeof (window.android) != "undefined") {
            window.android.callAndroidWebViewInitComplete();
     }
}
// 获取当前年份
function getCurtYear(){
    let mydate = new Date();
    let curtYear = mydate.getFullYear();
    return curtYear;
}
//获取当前日期 2018-10-01
function getCurtDate(){
    let mydate = new Date();
    let time = "" + mydate.getFullYear() + "-";
    // time += (mydate.getMonth()+1) + "-";
    // time += mydate.getDate();
    if (mydate.getMonth() + 1 <= 9){
        time += '0' + (mydate.getMonth() + 1) + "-";
    }else{
        time += (mydate.getMonth() + 1) + "-";
    }
    if (mydate.getDate()<=9){
        time +='0' + mydate.getDate();
    }else{
        time += mydate.getDate();
    }
    return time;
}
//获取网页数据
function getTabData(){
        checkWzElementChange();
        let CByfID = $('input[name=CBtable]').val();
        var wzInfos = new Array(), _ID = -1;
        for (var i = 1; i <= CByfID; i++) {
            if ($("#form_CBidone .table_border tbody #CBtr" + i + ">td.WZMC>input[type='text']").val() != '' && $("#form_CBidone .table_border tbody #CBtr" + i + ">td.WZMC>input[type='text']").val() != null) {
                var _ID = _ID +1;
                wzInfos[_ID] = {
                    ID:$("#form_CBidone .table_border tbody #CBtr" + i + " td #CBWZID" + i + "").val(),
                    WZDM: $("#form_CBidone .table_border tbody #CBtr" + i + " td #CBWZDM" + i + "").val(),
                    WZMC: $("#form_CBidone .table_border tbody #CBtr" + i + " td #CBWZMC" + i + "").val(),
                    ZGDONE: $("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDONE").val(),
                    ZGDTWO: $("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDTWO").val(),
                    ZGDTHREE: $("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDTHREE").val(),
                    ZGDFOUR: $("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDFOUR").val(),
                    ZGDFIVE: $("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDFIVE").val(),
                    ZGDAVG: $("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDAVE").val(),
                    CFLENGTH: "0",//丛幅长
                    CFWIDTH: "0",//丛幅宽
                    ZCS: $("#form_CBidone .table_border tbody #CBtr" + i + ">td input.ZCS").val(),
                    SWLXZ: $("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.SWLXZ").val(),
                    SWLGZ: $("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.SWLGZ").val(),
                    BZ: $("#form_CBidone .table_border tbody #CBtr" + i + ">td>div>span.BZ").text(),
                    DBMARK:$("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val()
                }
            }
        }
        let _GRASS_WZ = wzInfos.concat(_DELETEWZ);
        _DELETEWZ.length = 0;
        let _sampleplotid = $("#CBoneDm").val();
        if(_sampleplotid.split("-").length == 2){
         _sampleplotid = _sampleplotid+"-"+ getCurtYear();
        }
        return str = JSON.stringify({
                SHBZ: $("input[name=CBXXSHBZ]").val(),
                SAMPLEPLOTID: _sampleplotid,
                SAMPLEPLOTNAME: $("#CBoneNameC").text(),//名称
                YFMJ: $("#CBoneYFMJC").val(),//样方面积
                ZGD: $("#CBoneZFGLC").val(),//总覆盖率
                PJGD: $("#CBonePJGDC").val(),//平均高度
                GRASSID: $('#CBoneYFBHC').html(),//样方编号
                IMGPATH: _IMGPATH,
                PICNAME:_PICNAME,
                GRASS_WZ: _GRASS_WZ
        });
}
//保存数据
 function CBdataYFonesj(){
     if($("#CBoneNameC").html() == ""){
         alert("请选择一个样方");
         return;
     }
    let str = getTabData();
    if (window.android != null && typeof (window.android) != "undefined") {
        window.android.callAndroidSaveShowDialog(str);
    } else {
        alert(typeof (window.android));
    }
};
//提交数据
function CbCommitYfData(){
    if($("#CBoneNameC").html() == ""){
        alert("请选择一个样方");
        return;
    }
    //检查物种名称输入是否合法
    let isLegal = true;
    $("#form_CBidone .table_border tr td.WZMC").each(function(){
        $(this).css({"border":"1px #ccc solid"});
        if($(this).find($("input[name='wzmc']")).val() != ""){
            if($(this).find($("input[name='wzdm']")).val() == ""){
                $(this).css({"border":"1px solid #FF0000"});
                isLegal = false;
                return;
            }
        }
    });
    if(!isLegal){
        alert("请选择正确的植物名称");
        return;
    }
    let str = getTabData();
    if (window.android != null && typeof (window.android) != "undefined") {
        window.android.callAndroidCommitShowDialog(str);
    } else {
        alert(typeof (window.android));
    }
}
// 图片
function sjMultiUploadPicture() {
    if($("#CBoneYFBHC").html() == ""){
        return;
    }
    if (window.android != null && typeof (window.android) != "undefined") {
        window.android.callAndroidOpenCameraAndAlbum(1);
    } else {
        alert(typeof (window.android));
    }
};
function callJsShowPic(imgUrl) {
    _IMGPATH = '';
    $('.JG div').empty();
    let html = '', androidImgKey = "http://androidimg";
    //for (var i = 0; i < imgUrls.length; i++) {
        let imgpath = imgUrl.split('?')[0];
        _IMGPATH = imgpath;
        let picName = imgUrl.substring(imgUrl.lastIndexOf('/') + 1, imgUrl.lastIndexOf('?'));
        html += '<div style="width:180px;margin:3px;float:left;text-align: center;">'
            + '<img src=' + androidImgKey + imgUrl + ' style="width:120px;height:150px;" />'
            + '<span style="display:block;height:30px;font-size: 12px;padding: 5px;margin:0 auto; word-wrap:break-word;">' + picName + '</span>'
            + '</div>'
   // }
    $('.JG div').html(html);
}
//显示服务器存储图片
function showServerPic(picName){
    if(picName == null){
        return;
    }
    $('.JG > div').empty();
    let html = '';
    html += '<div style="width:180px;margin:3px 15px;float:left;text-align: center;">'
        +'<img src='+ Eg_url+'Upload/' + picName +' style="width:120px;height:150px;" />'
        +'<span style="display:block;height:30px;font-size: 12px;padding: 5px;margin:0 auto; word-wrap:break-word;">'+ picName+'</span>'
        +'</div>'
    $('.JG > div').html(html);
}
function callJsError() {
    $('.XZ_button_bc').remove('input');
}


 //草本信息
function callJsLocalExistCbYfInfo(data){
    //window.android.callAndroidShowLog("-----------0--------------");
    //window.android.callAndroidShowLog(JSON.stringify(data));
    //window.android.callAndroidShowLog("----aaa-------"+data.GRASS_WZ.length+" --------------"+$('input[name=CBtable]').val());
    showCbyfTabFun(data);
};
function callJsGetCjDate() {
    if (window.android != null && typeof (window.android) != "undefined") {
       let _curtDate = getCurtDate();
       window.android.callAndroidHtmlPageDateInfo(JSON.stringify({'DATE':_curtDate,'NAME':''}),false);
    } else {
        alert(typeof (window.android));
    }
}
function YSZPIC(id) {
    if($('#CBWZMC'+id+'').val() == ''){
        alert('请正确填写植物名称');
        return;
    }
    nameid = id;
    $.ajax({
        headers:{
            "Authorization":tokenStr
        },
        url: Wz_url + 'SpeciesSearch/' + $('#CBWZMC' + id + '').val(),
        type: "get",
        dataType: "json",
        contentType: 'application/json',
        success: function (data) {
            console.log(data);
            var html = '<div style="margin:3px 5px;">'
                + '<img src="' + Wz_url + 'Upload/' + data[0].PCPATH + '" style="width:120px;height:150px;display:block;margin:auto;" />'
                + '<spans style="display:block;height:20px;line-height:20px;font-size: 12px;text-align:center; word-wrap:break-word;overflow:hidden;">' + data[0].PCPATH + '</spans>'
                + '</div>'
            //$('.YSZ' + nameid + ' .YSZimg').html(html);
             $('#div_pic').html(html);
        }
    });

    //$('.YSZ'+id+'').toggle();
    $('#div_toggon_pic').toggle();
}
function YSZhide(id){
    $('.YSZ'+id+'').hide();
};
function picHide(){
    $('#div_toggon_pic').hide();
}
function closePhotoClick(){
     $('divdatapic').hide();
}
function yfPicUpload(){
   let picPath = "";
   if($('.JG > div  img').attr("src").indexOf("http://androidimg") == -1){//indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置。如果要检索的字符串值没有出现，则该方法返回 -1。
        window.android.callAndroidUploadPic("error");
        return;
   }
   let _fullpath = $('.JG > div  img').attr("src");//---完整路径--->http://androidimg/storage/emulated/0/jczApp/jczPictures/152500CGABPX20181018JG01E.png?0.5885204819954016
   window.android.callAndroidShowLog("-----------_fullpath---------------"+_fullpath);
   let _path = _fullpath.substring(_fullpath.indexOf("storage") - 1,_fullpath.lastIndexOf("?"));//----需要路径---->/storage/emulated/0/jczApp/jczPictures/152500CGABPX20181018JG01E.png
   window.android.callAndroidShowLog($('.JG > div  img').attr("src")+"-------"+_path);
   picPath = _path;
   window.android.callAndroidShowLog(picPath);
   window.android.callAndroidShowLog(picPath.substring(0,picPath.lastIndexOf(",")));
   window.android.callAndroidUploadPic(picPath);
}
//将数据显示到页面中
function showCbyfTabFun(data){
    _DELETEWZ.length = 0;
    _SERVER_DATA = data;
    //if(data.GRASS_WZ.length > $('input[name=CBtable]').val()){
        $('input[name=CBtable]').val(data.GRASS_WZ.length);
        wzHtmlTabInit();
    //}
    $("input[name=CBXXSHBZ]").val(data.SHBZ);
    $("#CBoneDm").val(data.SAMPLEPLOTID);//样地代码
    $("#CBoneNameC").text(data.SAMPLEPLOTNAME);//样地名称
    $("#CBoneYFMJC").val(data.YFMJ);//样方面积
    $("#CBoneZFGLC").val(data.ZGD);//总覆盖率
    $("#CBonePJGDC").val(data.PJGD);//平均高度
    $('#CBoneYFBHC').html(data.GRASSID);//样方编号
    for (var i = 0; i < data.GRASS_WZ.length; i++) {
        let _dbmark = data.GRASS_WZ[i].DBMARK;
        if(_dbmark == "" || _dbmark == null){
            _dbmark = 0;
        }
        if(_dbmark == 3){
            break;
        }
        $("#CBWZID" + (i + 1) + "").val(data.GRASS_WZ[i].ID);
        $("#CBWZMC" + (i + 1) + "").val(data.GRASS_WZ[i].WZMC);
        $("#CBWZDM" + (i + 1) + "").val(data.GRASS_WZ[i].WZDM);
        $("#CBtr" + (i + 1) + " td span input.ZGDONE").val(data.GRASS_WZ[i].ZGDONE);
        $("#CBtr" + (i + 1) + " td span input.ZGDTWO").val(data.GRASS_WZ[i].ZGDTWO);
        $("#CBtr" + (i + 1) + " td span input.ZGDTHREE").val(data.GRASS_WZ[i].ZGDTHREE);
        $("#CBtr" + (i + 1) + " td span input.ZGDFOUR").val(data.GRASS_WZ[i].ZGDFOUR);
        $("#CBtr" + (i + 1) + " td span input.ZGDFIVE").val(data.GRASS_WZ[i].ZGDFIVE);
        $("#CBtr" + (i + 1) + " td span input.ZGDAVE").val(data.GRASS_WZ[i].ZGDAVG);
        $("#CBtr" + (i + 1) + " td input.ZCS").val(data.GRASS_WZ[i].ZCS);
        $("#CBtr" + (i + 1) + " td span input.SWLXZ").val(data.GRASS_WZ[i].SWLXZ);
        $("#CBtr" + (i + 1) + " td span input.SWLGZ").val(data.GRASS_WZ[i].SWLGZ);
        $("#CBtr" + (i + 1) + " td span.BZ").html(data.GRASS_WZ[i].BZ);
        $("#DBMARK" + (i + 1) + "").val(_dbmark);
    }
    if(data.IMGPATH != undefined ){//server ---data中没有IMGPATH字段
       showServerPic(data.PICNAME);
       _PICNAME = data.PICNAME;
    }
};
//判断物种信息是否发生变化
function checkWzElementChange(){
    if(_SERVER_DATA != ""){
        let _GRASS_WZ = _SERVER_DATA.GRASS_WZ;
        let CByfID = $('input[name=CBtable]').val();
        for (let i = 1; i <= CByfID; i++) {
            if ($("#form_CBidone .table_border tbody #CBtr" + i + ">td.WZMC>input[type='text']").val() != '' && $("#form_CBidone .table_border tbody #CBtr" + i + ">td.WZMC>input[type='text']").val() != null) {
                let wz_len = _GRASS_WZ.length;
                for(let j = 0;j < wz_len;j++){
                    if($("#form_CBidone .table_border tbody #CBtr" + i + " td #CBWZMC" + i + "").val() == _GRASS_WZ[j].WZMC){
                       //该物种没有删除,判断是否修改
                       if($("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDONE").val() != _GRASS_WZ[j].ZGDONE){
                            $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val("2");
                            break;
                       }else if($("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDTWO").val() != _GRASS_WZ[j].ZGDTWO){
                            $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val("2");
                            break;
                       }else if($("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDTHREE").val() != _GRASS_WZ[j].ZGDTHREE){
                            $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val("2");
                            break;
                       }else if($("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDFOUR").val() != _GRASS_WZ[j].ZGDFOUR){
                            $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val("2");
                            break;
                       }else if($("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDFIVE").val() != _GRASS_WZ[j].ZGDFIVE){
                            $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val("2");
                            break;
                       }else if($("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.ZGDAVE").val() != _GRASS_WZ[j].ZGDAVG){
                            $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val("2");
                            break;
                       }else if($("#form_CBidone .table_border tbody #CBtr" + i + ">td>input.ZCS").val() != _GRASS_WZ[j].ZCS){
                            $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val("2");
                            break;
                       }else if($("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.SWLXZ").val() != _GRASS_WZ[j].SWLXZ){
                            $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val("2");
                             break;
                       }else if($("#form_CBidone .table_border tbody #CBtr" + i + ">td>span>input.SWLGZ").val() != _GRASS_WZ[j].SWLGZ){
                             $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val("2");
                             break;
                       }else if($("#form_CBidone .table_border tbody #CBtr" + i + ">td>div>span.BZ").text() != (_GRASS_WZ[j].BZ == null ? "" : _GRASS_WZ[j].BZ)){
                             $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val("2");
                             break;
                       }else{
                          let tempDBMARK = _GRASS_WZ[j].DBMARK;
                          if(tempDBMARK == ""){
                             tempDBMARK = 0;
                          }
                          $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val(tempDBMARK);
                       }
                       break;
                    }else{
                       $("#form_CBidone .table_border tbody #CBtr" + i + " td #DBMARK" + i + "").val("1");
                    }
                }
            }
        }
    }
}

//查询草本样方信息
function cbYfQuery(yfid){
    $.ajax({
        headers: {
           "Authorization":tokenStr
           },
        url:Eg_url+"GrassQuadrat/"+yfid,
        type: "get",
        dataType:"json",
        success: function (data) {
            //window.android.callAndroidShowLog(JSON.stringify(data));
            showCbyfTabFun(data[0]);
            showServerPic(data[0].PICNAME);
            _PICNAME = data[0].PICNAME;
        },
        error:function(data){
             window.android.callAndroidShowLog("-------cbYfQuery---error------"+JSON.stringify(data));
        }
    });
}